import random
import time

import dawdreamer as dmr
from server import Server

if __name__ =='__main__':
    with open(r'/reaper_remote/client/sylenth1_fxp_files.txt', 'rt', encoding='utf-8') as f:
        fxp_files = [line.strip() for line in f.readlines()]

    engine = dmr.RenderEngine(44100, 256)
    instr = engine.make_plugin_processor('instr_1', 'C:/VstPlugins/64bit/Sylenth1.dll')
    engine.load_graph([(instr, [])])
    preset = random.choice(fxp_files)
    instr.load_preset(r"C:\Users\Dajun\Documents\LennarDigital\Sylenth1\Presets\summertime\Ultrasonic LD - Brooks 15.fxp")

    params = [instr.get_parameter(i) for i in range(instr.get_plugin_parameter_size())]
    print(params)

    with Server(command_size=10240, data_size=10240) as ser:
        ser.set_params(params)
print('正在等待Reaper端回应……')
r = ''
while r == '':
    r = ser.recv_data()
    time.sleep(0.1)

print('已收到：' + r)






